import './assets/main.css'
import '@/utils/browserPatch'

import { createApp } from 'vue'
import pinia from '@/stores/index'

import App from './App.vue'
import router from './router'

// 引入ElementUI
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// import locale from 'element-plus/es/locale/lang/zh-cn' // 中文
import localeEn from 'element-plus/es/locale/lang/en' // 英文
import * as ElementPlusIconsVue from '@element-plus/icons-vue' // 引入icon
import 'default-passive-events'
import moment from 'moment'
import JsonViewer from 'vue-json-viewer' // json 转 html片段
import 'vue-json-viewer/style.css'

const app = createApp(App)

app.config.globalProperties.$moment = moment;
app.config.globalProperties.$formatDate = (value: any) => {
  if (!value) return '';
  return moment(value).format('YYYY-DD-MM');
};
// 全局组件挂载
// 使用element-plus，设置默认语言及全局size
app.use(ElementPlus, {
  zIndex: 3000,
  locale: localeEn,
  // 支持 large、default、small
  size: 'default' || "default",
})

// 全局挂载 @element-plus/icons-vue
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(JsonViewer)

app.use(pinia).use(router).mount('#app')
